package eworldpacs.ui;

import leadtools.dicom.DicomDataSet;
import leadtools.dicom.DicomElement;
import leadtools.dicom.DicomVrType;

public class ElementInfo {

   DicomElement _element;
   private String _tag;
   private String _name;
   private DicomVrType _vr;
   private long _length;
   private String _value;
   
   private ElementInfo(DicomElement element, String elementValue)
   {
      if (element != null)
      {
        _tag = DicomDemoUtils.ElementToString(element.getTag());
        _name = DicomDemoUtils.ElementNameToString(element);
        _vr = element.getVr();
        _length = element.getLength();
        _value = elementValue;
      }
      else
      {
      }
   }
   
   public static ElementInfo create(DicomDataSet ds, DicomElement element, int maxDisplayLength){
     String val = "";
      if (element.getLength() > maxDisplayLength)
      {
         byte[] ba = ds.getBinaryValue(element, maxDisplayLength);
         val = DicomDemoUtils.ConvertByteArrayToString(ba);
      }
      else
      {
         val = ds.getConvertValue(element);
      }
      return new ElementInfo(element, val);
   }
   
   public String getTag(){
     return _tag;
   }
   
   public String getName(){
     return _name;
   }
   
   public String getVR(){
     return _vr.toString();
   }
   
   public String getLength(){
     return Long.toString(_length);
   }
   
   public String getValue(){
     return _value;
   }
}
